'use strict'

const Koa = require('koa');
const bodyparser = require('koa-bodyparser');
const router = require('./router');
const cors = require('koa-cors');
const {sync} = require('./model');

// (async () => {
//     // 测试数据库是否连接成功
//     try {
//         await sequelize.authenticate();
//         console.log('数据库连接成功');
//     } catch (error) {
//         console.error('数据库连接失败', error);
//     }
// })();

let app = new Koa()

app.use(cors())
app.use(bodyparser())
app.use(router.routes())

let port = 8080;
app.listen(port)
console.log(`Server is running http://localhost:${port}`);